#ifndef INFINITY_APPLICATION_H
#	define INFINITY_APPLICATION_H

#include "base/singleton.h"
#include "system/application.h"
#include "servicemanager.h"

#include "system/applicationsetup.h"
#include "system/window.h"
#include "system/timer.h"
#include "graphics/renderWindow.h"
#include "graphics/node.h"
#include "windoweventlistener.h"

namespace infinity {

class ServiceInput;
class ServicePhysics;
class ServiceAudio;

class Application
:	public dw::system::Application
,	public ServiceManager
,	public dw::base::Singleton< Application, false >
{
public :
	bool onSetup(int argc, char** argv);
	void onIdle();
	void onShutdown();

public : //! @name ServiceManager overrides
	//! @{
	virtual void renderDebug();
	//! @}

public : //! @name State
	//! @{
	virtual Setup& getSetup() { return m_setup; }
	const dw::system::Window& getWindow() const { return *m_window; }
	//! @}

protected : //! @name Construction & destruction
	//! @{
	friend class dw::base::Singleton< Application, false >;

	Application();
	~Application();
	//! @}

private : //! @name Helpers
	//! @{
	void initializeServices();
	void initializeGameModes();
	void initializeGraphics();
	void recomputeProjection();
	//! @}

private : //! @name Data
	//! @{
	Setup m_setup;
	dw::system::Timer m_timer;
	dw::system::Window* m_window;
	WindowEventListener m_windowEventListener;
	//! @}
};

} // namespace infinity 

#endif // !INFINITY_APPLICATION_H
